import { ICondition } from '../../../interfaces';
import service from './service';

/**
 * 获取数据
 * @param spaceid 系统参数spaceid
 * @param systemid 项目的systemid
 * @param refsystemid 项目的refsystemid
 * @param modelid 模块id
 * @param table_name 表名
 * @param condition 内容
 */
export default async function get_data(spaceid: string, systemid: string, refsystemid: string, modelid: string, table_name: string, condition: ICondition) {
	const params = {
		condition: condition || {
			paging: {
				index: 1,
				size: 12
			},
			param: {},
			sort: {}
		},
		emptydataflag: 0,
		modelid,
		refsystemid,
		spaceid,
		systemid
	};
	const data = await service(spaceid, 'dataservice.findbusidata', params);
	const docDataStore = data.docDataStore;
	const table_data = docDataStore[table_name];
	const dataArray = table_data.dataArray;
	return dataArray;
}
